home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / CHASSIS_ / MAINDRAW.C < prev    next >
Text File  |  1992-05-20  |  3KB  |  108 lines

  1. /************************************************************************************/
  2. /*    MainDrawProc                                                                    */
  3. /*  This routine should be invoked between a BeginUpdate and EndUpdate sequence,    */
  4. /*    usually after an Update event in the main event loop.                            */
  5. /************************************************************************************/
  6.  
  7. #include "MyHeaders.h"
  8.  
  9. int MainDrawProc ()
  10. {
  11.     int        MainDrawRetCode = 0;
  12.     
  13.     Rect        IRect = {10,10, 42,42};            /* placement of icon bitmap            */
  14.     Handle        IHandle;                        /* handle to icon                    */
  15.     CIconHandle    CIHandle;                        /* handle to icon                    */
  16.     PicHandle    thePic;                            /* for background picture            */
  17.     
  18.     windSub = 0;                                /* point to window record            */
  19.     SetPort (windTbl[windSub].windPtr);            /* set as the grafPort                */
  20.  
  21.  
  22.             /********************************************/
  23.             /* Example of displaying text from a        */
  24.             /* resource file.  THIS IS THE PREFERRED    */
  25.             /* WAY OF DISPLAYING STATIC TEXT.            */
  26.             /********************************************/
  27.             
  28.     TextFont(geneva);
  29.     TextFace(NIL);
  30.     TextSize(10);
  31.     SetRect (&workRect, 10,52,  350,171);
  32.     workHandle = GetResource('TEXT', 128);
  33.     HLock(workHandle);
  34.     worklong = SizeResource(workHandle);
  35.     TextBox ((*workHandle), worklong, &workRect, teJustLeft);
  36.     HUnlock(workHandle);
  37.  
  38.             /********************************************/
  39.             /* Example of writing version information    */
  40.             /********************************************/
  41.  
  42.     TextSize(9);
  43.     workRect = windTbl[0].windRec.port.portRect;
  44.     workRect.top = workRect.bottom - 26;
  45.     workRect.left +=4;
  46.     workRect.right -=4;
  47.     TextBox (&versLongStr[1], (long) versLongStr[0], &workRect, teJustLeft);
  48.  
  49.             /********************************************/
  50.             /* Example of drawing text.                    */
  51.             /********************************************/
  52.             
  53.     TextFont(geneva);
  54.     TextFace(bold);
  55.     TextSize(20);
  56.     MoveTo (65,35);
  57.     DrawString ("\pChassis");
  58.  
  59.  
  60.             /********************************************/
  61.             /* Example of displaying an icon from a        */
  62.             /* resource file.                            */
  63.             /* myResRefNum is application's resource    */
  64.             /* file reference number obtained near the    */
  65.             /* beginning of the program.                */
  66.             /********************************************/
  67.  
  68.     UseResFile (myResRefNum);
  69.     if (useColor)
  70.         {
  71.         CIHandle = GetCIcon (128);
  72.         PlotCIcon (&IRect, CIHandle);
  73.         }
  74.     else
  75.         {
  76.         IHandle = GetResource ('ICN#', 128);
  77.         PlotIcon (&IRect, IHandle);
  78.         }
  79.  
  80.  
  81.             /********************************************/
  82.             /* Example of using drawing commands.        */
  83.             /********************************************/
  84. /****            
  85.     SetRect (&workRect, 300,10,  340,50);
  86.     FrameRect (&workRect);
  87.     FrameOval (&workRect);
  88.     MoveTo (300,10);
  89.     Line (38,38);
  90.     MoveTo (339,10);
  91.     Line (-38,38);
  92. ****/    
  93.  
  94.             /********************************************/
  95.             /* Example of displaying a picture            */
  96.             /* from a resource file.  You can use this    */
  97.             /* method to create a "background" picture.    */ 
  98.             /********************************************/
  99. /****            
  100.     UseResFile (myResRefNum);            
  101.     thePic = (PicHandle) GetResource ('PICT', 128);
  102.     workRect = (**thePic).picFrame;
  103.     DrawPicture (thePic,&workRect);
  104. ****/    
  105.     
  106.     return MainDrawRetCode;
  107. }
  108.